import fetch from "common/src/utils/fetch";

/**
 *  根据学期获取周数
 */
function listWeekNumber(calendarId) {
  return fetch({
    url:
      "/api/electionservice/schoolExamArrange/listWeekNumber?calendarId=" +
      calendarId,
    method: "get"
  });
}

/**
 *  导出跨校区学生
 */
function exportCrossStudent(calendarId) {
  return fetch({
    url:
      "/api/electionservice/schoolExamArrange/exportCrossCampusStudent?calendarId=" +
      calendarId,
    method: "get"
  });
}

/**
 *跨校区考试明细表(导出)
 */
function exportCrossCampusStudent(data) {
  return fetch({
    url: '/api/electionservice/undergraduateExamExportDetail/exportCrossCampusStudentExaminationPage',
    method: 'post',
    data
  })
}

/**
 *  手动排考校验课程组是否有相同学生或者多个教学班有相同学生，否则提示不能安排同一个时间
 */
function manualSchoolExamCheek(data) {
  return fetch({
    url: "/api/electionservice/schoolExamArrange/manualSchoolExamCheek",
    method: "post",
    data
  });
}

/**
 *  学校排考管理手动排考保存时间
 */
function manualSchoolSaveTime(data) {
  return fetch({
    url: "/api/electionservice/schoolExamArrange/manualSchoolSaveTime",
    method: "post",
    data
  });
}

/**
 *  学校排考删除排考
 */
function deleteExam(data) {
  return fetch({
    url: "/api/electionservice/schoolExamArrange/deleteExam",
    method: "post",
    data
  });
}

/**
 *  删除考场
 */
function delExamRoom(data) {
  return fetch({
    url: "/api/electionservice/schoolExamArrange/deleteExamRoom",
    method: "post",
    data
  });
}

/**
 *  获取排考人数
 */
function findElcNumber(data) {
  return fetch({
    url: "/api/electionservice/schoolExamArrange/findElcNumber",
    method: "post",
    data
  });
}

/**
 *  学校排考自动排考
 */
function autoSchoolExam(data) {
  return fetch({
    url: "/api/electionservice/schoolExamArrange/autoSchoolExam",
    method: "post",
    data
  });
}

const pageUrl = "/api/electionservice/schoolExamArrange/schoolExamArrangeQuery";

/**
 * 获取 key
 */
function getResultByKey(key) {
  return fetch({
    url: "/api/electionservice/examinationMethod/result/" + key,
    method: "get"
  });
}

/**
 *  通过额定人数 获取周次 节次信息
 */
function getTimeInfo(calendarId,examType) {
  return fetch({
    url:
      "/api/electionservice/undergraduateExamNumberTime/getTimeInfo?calendarId=" +
      calendarId + "&examType="+ examType,
    method: "get"
  });
}

/**
 *  学校排考管理手动排考保存考场
 */
function manualSchoolSaveRoom(data) {
  return fetch({
    url: "/api/electionservice/schoolExamArrange/manualSchoolSaveRoom",
    method: "post",
    data
  });
}

/**
 * 获取 key
 */
function getAutoExamKey(key) {
  return fetch({
    url:
      "/api/electionservice/schoolExamArrange/findAutoSchoolExamStatus?key=" +
      key,
    method: "get"
  });
}

const weeks = [
  { label: "星期一", value: 1 },
  { label: "星期二", value: 2 },
  { label: "星期三", value: 3 },
  { label: "星期四", value: 4 },
  { label: "星期五", value: 5 },
  { label: "星期六", value: 6 },
  { label: "星期日", value: 7 }
];

export default {
  listWeekNumber: listWeekNumber,
  weeks: weeks,
  exportCrossStudent: exportCrossStudent,
  exportCrossCampusStudent: exportCrossCampusStudent,
  manualSchoolExamCheek: manualSchoolExamCheek,
  manualSchoolSaveTime: manualSchoolSaveTime,
  deleteExam: deleteExam,
  autoSchoolExam: autoSchoolExam,
  pageUrl: pageUrl,
  getResultByKey: getResultByKey,
  getTimeInfo: getTimeInfo,
  manualSchoolSaveRoom: manualSchoolSaveRoom,
  getAutoExamKey: getAutoExamKey,
  findElcNumber: findElcNumber,
  delExamRoom: delExamRoom
};
